package com.shuai.utils;


import com.alibaba.fastjson2.JSONObject;

/**
 * 响应的工具类
 */
public class R extends JSONObject {

    public R(ResultCode res) {
        super.put("code", res.getCode());
        super.put("msg", res.getMsg());
    }

    public R(ResultCode res, Object data) {
        super.put("code", res.getCode());
        super.put("msg", res.getMsg());
        super.put("data", data);
    }

    public static R ok() {
        return new R(ResultCode.SUCCESS);
    }

    public static R ok(Object data) {
        return new R(ResultCode.SUCCESS, data);
    }

    public static R er() {
        return new R(ResultCode.ERROR);
    }

    public static R checkError() {
        return new R(ResultCode.CHECKERROR);
    }

    public static R checkProjectERROR() {
        return new R(ResultCode.SUBPROJECTERROR);
    }

    ;

    public static R checkTaskNameError() {
        return new R(ResultCode.TASKNAMEERROR);
    }
}